package org.dromara.oce.controller.admin;

import cn.dev33.satoken.annotation.SaCheckPermission;
import lombok.RequiredArgsConstructor;
import org.dromara.common.core.domain.R;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.web.core.BaseController;
import org.dromara.oce.domain.qo.OceProductStoreQo;
import org.dromara.oce.domain.vo.OceProductStoreVo;
import org.dromara.oce.service.OceProductStoreService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 商品库
 *
 * @author dsbb
 * @date 2025-06-09
 * @module 管理平台接口
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/oce/productStore")
public class OceProductStoreController extends BaseController {

    private final OceProductStoreService oceProductStoreService;

    /**
     * 查询商品库列表
     */
    @SaCheckPermission("oce:productStore:list")
    @GetMapping("/list")
    public TableDataInfo<OceProductStoreVo> list(OceProductStoreQo qo, PageQuery pageQuery) {
        return oceProductStoreService.queryPageList(qo, pageQuery);
    }

    /**
     * 同步商品库
     * @return
     */
    @RepeatSubmit
    @SaCheckPermission("oce:productStore:syncProductStore")
    @GetMapping("/syncProductStore")
    public R syncProductStore(Long accountId){
        oceProductStoreService.syncProductStore(accountId,null);
        return R.ok();
    }


}
